package processes

import (
	"fmt"
	"go-web-learning/src/02_message_system/02_message_system/chatroom/common/constants"
	"go-web-learning/src/02_message_system/02_message_system/chatroom/common/message"
	"go-web-learning/src/02_message_system/02_message_system/chatroom/common/netWork"
)

type ErrorProcess struct {
	Conn netWork.Conn
}

func (e *ErrorProcess) ServerErrorProcess() (err error) {
	respMsg := message.Message{}
	respMsg.SetType(constants.MSG_TYPE_ERROR_RESP)
	respData := message.SrvMsgBase{
		Code: constants.RESP_CODE_UNKNOWN_ERR,
		Msg:  "未知类型，暂时无法处理",
	}
	err = respMsg.SetData(respData)
	if err != nil {
		fmt.Println("resp set data err:", err)
		return err
	}
	// 发送
	e.Conn.SetMsg(respMsg)
	_, err = e.Conn.Send()
	return
}
